/*
EP3D is a real-time 3D planet engine , which in addition to providing 
substandard scene rendering and scene management, of course, it also 
provides some basic class libraries to build the entire virtual 
planet, or even the entire universe.

Copyright (C) 2010  Hongjiang Zhang	(zhjwyat@gmail.com)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef EP3D_CAMERASCENENODE_H
#define EP3D_CAMERASCENENODE_H
#include "EP3DSceneNode.h"
#include "EP3DFrustum.h"

namespace EP3D
{
	class SceneManager;
	class EP3DEXPORT CameraSceneNode
		:public SceneNode
	{
		DeclareRtti;
	public:
		CameraSceneNode(SceneNode* pkParent, SceneManager* pkMgr, const Transformf& t, const Vector3f& at);

		virtual const Matrix4f& GetViewMatrix() const;

		virtual void SetProjectionMatrix(const Matrix4f& proj);
		virtual const Matrix4f& GetProjectionMatrix() const;

		virtual void SetTarget(const Vector3f& pos);
		virtual void SetRotation(const Quaternionf& q);
		virtual void SetUpVector(const Vector3f& v);

		virtual const Vector3f& GetTarget() const;
		virtual const Vector3f& GetUpVector() const;

		virtual f32 GetNearValue() const;
		virtual f32 GetFarValue() const;
		virtual f32 GetAspectRatio() const;
		virtual f32 GetFov() const;

		virtual void SetNearValue(f32 f);
		virtual void SetFarValue(f32 f);
		virtual void SetAspectRatio(f32 f);
		virtual void SetFov(f32 f);

		virtual void Render();

		virtual const BBox3f& GetBoundingBox() const;
		virtual const Frustum* GetFrustum() const;

	protected:
		void CalculateProjectionMatrix();
		void CalculateViewArea();

		Vector3f m_kTarget;
		Vector3f m_kUpVector;

		f32 m_fFov;
		f32 m_fAspect;
		f32 m_fZNear;
		f32 m_fZFar;

		Frustum m_kFrustum;
		SceneManager* m_pkMgr;
	};
}
#endif


